﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DesktopClient {
	public partial class LogIn : Form {
		
		public LogIn() {
			InitializeComponent();
            ServerProvider.ServiceSoapClient cl = new DesktopClient.ServerProvider.ServiceSoapClient();
		}
                		
		private void loginButton_Click(object sender, EventArgs e) {
            ServerProvider.ServiceSoapClient cl = new DesktopClient.ServerProvider.ServiceSoapClient();
			if (loginBox.Text.Length == 0) {
				warning.Text = "You must type at least one character!";
				return;
			}
			bool result = cl.LogIn(loginBox.Text); 
            if (result == false)
            {
                warning.Text = "Login " + loginBox.Text + " is currently in use";
                loginBox.Clear();
                return;
            }
            else
            {
                warning.Text = "";
                this.Visible = false;
                (new RoomList(this, loginBox.Text)).ShowDialog();
                loginBox.Clear();
            }
		}

        private void Enter(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                this.loginButton_Click(sender, e);
            }
        }
	}
}
